from socket import *


HOST = '127.0.0.1'
PORT = 33067
ADDR = (HOST, PORT)


tcp_client = socket(AF_INET, SOCK_STREAM)   # 创建套接字
tcp_client.connect(ADDR)    # 链接服务器

while True:
    data = input('> ').encode('utf-8')
    if not data:
        break
    tcp_client.send(data)   # 发送数据
    rec_data = tcp_client.recv(1024)    # 接受数据
    if not rec_data:
        break
    print(rec_data.decode('utf-8'))

tcp_client.close()
